package lab_15.com.acme.bankapp.domain.bank.Email;

import lab_15.com.acme.bankapp.domain.bank.Client;

public class EmailService {

	static private EmailQueue emailQueue = new EmailQueue();


	public static void sendNotificationEmail(Client client) {
		try{
		emailQueue.add(new Email(String.format("%s@acme.com", client.getName()), client.getName(),
				String.format("Hello %s %s ...", client.getClientSalutation(), client.getName())));
		}
		catch (IllegalStateException e) { // emailQueue in the closing mode, and doesn't accept new messages
			System.out.println(e.getMessage());
		}

	}

	public static void close() {
		emailQueue.close();
	}
}
